<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
        <title>Jalava : Web-based Diagram Editor</title>
        <script language="JavaScript" src="./js/Jalava.js"></script>
        <script language="JavaScript">

  

            function dada(){
                // var url1 = "http://marinoflow.appspot.com/nuovastr.txt";
                var url1 = "http://marinoflow.appspot.com/ProvaServlet";
                var jsonString = Jalava.diagram.persist();
                if (confirm(jsonString)) {
                    // do things if OK
                }

                objXml = new XMLHttpRequest();
                objXml.open("POST",url1,false);
                objXml.setRequestHeader('Content-Type',"text/plain");
                // objXml.setRequestHeader("Content-Length", jsonString.length);
                //objXml.sendAsBinary(jsonString);
               // objXml.send(jsonString);
                objXml.send(jsonString);
                str = objXml.responseText;
                confirm("RISP: " +str);

            }
            function dodo(){
                var url = "http://marinoflow.appspot.com/nstr.txt";
         
                objXml = new XMLHttpRequest();
                objXml.open("GET",url,false);
                objXml.send(null);
                str = objXml.responseText;
                confirm("ECCO " +str);
                Jalava.diagram.load(str);
            }
            function dadaOLD(){
                // var url1 = "http://marinoflow.appspot.com/nuovastr.txt";
                var url1 = "http://marinoflow.appspot.com/nuovastr.txt";
                var jsonString = Jalava.diagram.persist();
                if (confirm(jsonString)) {
                    // do things if OK
                }

                objXml = new XMLHttpRequest();               
                objXml.open("POST",url1,true);
                //  objXml.setRequestHeader('Content-Type',"text/plain");
                objXml.setRequestHeader("Content-Length", jsonString.length);
                objXml.sendAsBinary(jsonString);
                //    objXml.send(jsonString);
                str = objXml.responseText;
                confirm("RISP: " +str);

            }
            
            // initialise Jalava here
            function initJalava(){
                Jalava.diagram = new Diagram(220, 100, "550", "600");
                var palette = new Palette(new FlowChartPaletteFactory(), 0, 100, 200);
                palette.addItem("rect", "Processing",  Palette.DRAG_TOOL, "./img/rect.gif");
                palette.addItem("connection", "Connection",  Palette.CLICK_TOOL, "./img/line.gif");
                palette.addItem("diamond", "Decision", Palette.DRAG_TOOL, "./img/diamond.gif");
                palette.addItem("parallel", "Input/Output", Palette.DRAG_TOOL, "./img/parallel.gif");
                palette.addItem("ellipse", "Connection", Palette.DRAG_TOOL, "./img/ellipse.gif");
                palette.addItem("rounded", "Start/End", Palette.DRAG_TOOL, "./img/ellipse.gif");
                Jalava.propertyPage = new FlowChartPropertyPage(20, 240, 10);

                /*
                 *  ESEMPIO CVHE SEMBRA FUNZIONARE A PARTE ICONE CHE NON SONO LE VARIE FIRUINE
                 *   MA SEMPRE RETTANGOLI


                Jalava.diagram = new Diagram(220, 100, "550", "600");
                var palette = new Palette(new FlowChartPaletteFactory(), 0, 100, 200);
                palette.addItem("rect", "Processing",  Palette.DRAG_TOOL, "./img/rect.gif");
                palette.addItem("connection", "Connection",  Palette.CLICK_TOOL, "./img/line.gif");
                palette.addItem("diamond", "Decision", Palette.DRAG_TOOL, "./img/diamond.gif");
                palette.addItem("parallel", "Input/Output", Palette.DRAG_TOOL, "./img/parallel.gif");
                palette.addItem("ellipse", "Connection", Palette.DRAG_TOOL, "./img/ellipse.gif");
                palette.addItem("rounded", "Start/End", Palette.DRAG_TOOL, "./img/ellipse.gif");
                Jalava.propertyPage = new FlowChartPropertyPage(20, 240, 10);
                 */
               
                
            }

            // start Jalava
            Jalava.addModule("FlowChartPaletteFactory");
            Jalava.addModule("FlowChartPropertyPage");
            Jalava.addModule("UrlGradientBlock");

            Jalava.start(initJalava);

        </script>

    </head>
    <body>
        <FORM >
            <INPUT type="button" value="spedire" name="button44" onClick="dada();">
        </FORM>
        <FORM method="POST" action="http://marinoflow.appspot.com/ProvaServlet">
            <INPUT type="button" value="See JSon" name="button2" onClick="dada();">
            <INPUT type="button" value="load" name="button3" onClick="dodo();">
            <INPUT TYPE="SUBMIT" NAME="pippo" VALUE="Click Me">
        </FORM>

    </body>
</html>  